<include file="Public:headerNew" />
<style>
.ui-datepicker-calendar {
    display: none;

    }
</style>
<load href="__PUBLIC__/Js/jqueryUI/jquery-ui-zh.custom.js" />

<load href="__PUBLIC__/Js/jqueryUI/jquery-ui-1.8.16.custom.min.js" />

<load href="__PUBLIC__/Css/jqueryUI/jquery-ui-1.8.21.custom.css" />
<div class="titleone"><h1 class="fLeft">添加水电表计量</h1><a href="__URL__/comlist/pid/{$com.zoneid}"><div class="returnimg"></div></a></div>
<div id="result" class="result none"></div>
<div id="main" class="main full" >
<script language="javascript">
			$(function(){				// Datepicker
				$('#datepicker').datepicker({
					
					changeMonth: true,
        			changeYear: true,
					showMonthAfterYear: true,
             		dateFormat: 'MM yy',
					onSelect: function(dateText, inst) {
						var month = pad(Number($(".ui-datepicker-month :selected").val())+1,2);
                		var year = $(".ui-datepicker-year :selected").val();
						document.getElementById('thedate').value=year+'-'+month+'-'+'01'; 
						}

				});
				
                   
			});
			//前位补0函数
			function pad(num, n) {

   			 var len = num.toString().length;

   				 while(len < n) {

        			num = "0" + num;

        			len++;

    			}

    			return num;

			}

			function submitForm() { 
									// inside event callbacks 'this' is the DOM element so we first 
									// wrap it in a jQuery object and then invoke ajaxSubmit 
							//添加地区信息
						var month = pad(Number($(".ui-datepicker-month :selected").val())+1,2);
                		var year = $(".ui-datepicker-year :selected").val();
						$('#thedate').val(year+'-'+month+'-'+'01');
						$('#form1').submit();
       					return false;	
								
   			};
			
			
			function wsunMeter(i){
					var monw=0;
					var acount=0;
					if(!isNaN($('#wmeterNum1_'+i).val())){
					if($('#wmeterNum1_'+i).val()>$('#wmeterNum2_'+i).val()){
						monw=($('#wmeterNum1_'+i).val()-$('#wmeterNum2_'+i).val());
						$('#wcount_'+i).html(monw);
						$('#wpay_'+i).html(mul($('#wmeterprice_'+i).val(),monw));
						for(n=1;n<=$('#wNum').val();n++){
							acount=acount+Number($('#wpay_'+n).html());
						}
						$('#wcounts').html(acount);
						$('#wNumCount').val(acount);
						
					}
				}else{
					alert('请确保输入的为数字');
				}	
			}
			function esunMeter(i){
					var monw=0;
					var acount=0;
					if(!isNaN($('#emeterNum1_'+i).val())){
					if($('#emeterNum1_'+i).val()>$('#emeterNum2_'+i).val()){
						monw=($('#emeterNum1_'+i).val()-$('#emeterNum2_'+i).val());
						$('#ecount_'+i).html(monw);
						$('#epay_'+i).html(mul($('#emeterprice_'+i).val(),monw));
						for(n=1;n<=$('#eNum').val();n++){
							acount=acount+Number($('#epay_'+n).html());
						}
						$('#ecounts').html(acount);
						$('#eNumCount').val(acount);
						
					}
				}else{
					alert('请确保输入的为数字');
				}	
			}
			function mul(n1, n2) {
    		var m=0, s1=n1.toString(), s2=n2.toString();
    		try {
        		m += s1.split(".")[1].length
    			} catch(e) {
    		}
   			 try {
       		 m += s2.split(".")[1].length
    		} catch(e){
   			 }
    		return Number(s1.replace(".","")) * Number(s2.replace(".","")) / Math.pow(10, m)
}
</script>
<div id="result" class="result none"></div>
<form method='post' id="form1" name="form1" action="__URL__/insert"  enctype="multipart/form-data">
<div class="metroTitle">添加新数据  {$com.name}[{$com.bizSid}]<input type="hidden" name="bizid" id="bizid" value="{$com.id}"/><input type="hidden" name="bizSid" id="bizSid" value="{$com.bizSid}"/></div>	<div style="float:right; width:240px; position:relative; margin-top:-37px;font-size:12px;"><div id="datepicker"></div><input type='hidden' id='thedate' name='thedate' /></div>	
<ul class="pt_list" id="pt_list">

          <li  style="height:220px;">

                    <div class="thumb"><span>1</span></div>

                    <h3>添加水表数据</h3>

                    <div class="thumbr">
                    <table width="900" border="0" cellspacing="3" cellpadding="3" class="mytable" id="wmeter">
 <tr>
 <th>&nbsp;表名称&nbsp;</th>
 <th>本月读数</th>
 <th>上月读数</th>
 <th>本月电量</th>
 <th>水费单价</th>
 <th>&nbsp;合 计&nbsp;</th>
 </tr>
 <volist name="listw" id="vo">
  <tr>
    <td><input type="hidden" name="wids[]" id="ids_{$i}" value="{$vo.id}"/>{$vo.meterid}</td>
    <td>
      
      <input type="text" name="wmeterNum1[]" id="wmeterNum1_{$i}" value="" onBlur="wsunMeter({$i})" />
    </td>
    <td>
      <input type="text" name="wmeterNum2[]" id="wmeterNum2_{$i}" value="{$vo.lastnum}" onBlur="wsunMeter({$i})"/></td>
  <td id="wcount_{$i}">0.00
     </td>
    <td> <input type="text" name="wmeterprice[]" id="wmeterprice_{$i}" value="{$vo.m_price}" onBlur="wsunMeter({$i})"/>
     </td>
         <td id="wpay_{$i}">0.00
     </td>
  </tr>
  </volist>
</table>


                    </div>
                    <div class="countbottom"><input type="hidden" name="wNum" id="wNum" value="{$com.meternum1}"/>水费合计:<div style="margin-left:90px;margin-top:-18px;" id="wcounts">0.00</div><input type="hidden" name="wNumCount" id="wNumCount" value="0"/></div>
                    </li>
          <li  style="height:220px;">

                    <div class="thumb"><span>2</span></div>

                    <h3>添加电表数据</h3>

                    <div class="thumbr">
                <table width="900" border="0" cellspacing="3" cellpadding="3" class="mytable" id="emeter">
 <tr>
 <th>&nbsp;表名称&nbsp;</th>
 <th>本月读数</th>
 <th>上月读数</th>
 <th>本月电量</th>
 <th>电费单价</th>
 <th>&nbsp;合 计&nbsp;</th>
 </tr>
 <volist name="liste" id="vo">
   <tr>
    <td><input type="hidden" name="eids[]" id="ids_{$i}" value="{$vo.id}"/>{$vo.meterid}</td>
    <td>
      
      <input type="text" name="emeterNum1[]" id="emeterNum1_{$i}" value="" onBlur="esunMeter({$i})" />
    </td>
    <td>
      <input type="text" name="emeterNum2[]" id="emeterNum2_{$i}" value="{$vo.lastnum}" onBlur="esunMeter({$i})"/></td>
  <td id="ecount_{$i}">0.00
     </td>
    <td> <input type="text" name="emeterprice[]" id="emeterprice_{$i}" value="{$vo.m_price}" onBlur="esunMeter({$i})" />
    
     </td>
         <td id="epay_{$i}">0.00
     </td>
  </tr>
  </volist>
</table>   
                    </div>
                    <div class="countbottom"><input type="hidden" name="eNum" id="eNum" value="{$com.meternum2}"/>电费合计:<div style="margin-left:90px;margin-top:-18px;" id="ecounts">0.00</div><input type="hidden" name="eNumCount" id="eNumCount" value="0"/></div>
                    </li>           
                    </ul>
    <div class="toolPanel">
        <div style="width:99%;margin:5px">
        <input type="hidden" name="user_id" value="<?php echo $_SESSION[C('USER_AUTH_KEY')] ?>">
             <div class="impBtnN fRig"><a href="#" onclick="document.forms['form1'].reset()" id="buttonclearBlock" ></a></div>
            <div class="impBtnN fRig"><a href="#" onclick="submitForm();" id="buttonSaveBlock" ></a></div>
          
        </div>
    </div>
    </form>
</div>
